#!/bin/bash
# 获取Docker官方仓库crt证书
# 需要安装Openssl
# By gas

HOST="registry-1.docker.io"
PORT=443
dirPath="/etc/ssl/certs"
crtPath="$dirPath/$HOST.crt"
if [ ! -d $dirPath ]; then
    mkdir -p $dirPath
fi
# 导出证书
echo|openssl s_client -showcerts -connect $HOST:$PORT 2>&1|sed \
  -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > $crtPath
